package com.qc.ayouth.shop.admin.controller.users;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qc.ayouth.shop.admin.beans.AdminResponseVO;
import com.qc.ayouth.shop.admin.service.user.AdminUserAddressService;
import com.qc.ayouth.shop.admin.service.user.AdminUserFeedbackService;
import com.qc.ayouth.shop.dbs.entity.TUserAddress;
import com.qc.ayouth.shop.dbs.entity.TUserFeedback;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户意见反馈
 * Created by Haojg on 2020/7/8
 */
@RestController
@RequestMapping("/api/admin/feedback")
@Validated
@Slf4j
public class AdminUserFeedbackController {
    @Autowired
    AdminUserFeedbackService adminUserFeedbackService;

    @RequiresPermissions("users:feedback")
    @GetMapping("/list")
    public AdminResponseVO list(@RequestParam(defaultValue = "") String username,
                                @RequestParam(defaultValue = "1") Integer pageNo,
                                @RequestParam(defaultValue = "15") Integer pageSize) {
        log.info("user feedback list start");
        AdminResponseVO vo = new AdminResponseVO();

        // 获取列表
        IPage<TUserFeedback> feedbackIPage = adminUserFeedbackService.searchUserFeedbackList(username, pageNo, pageSize);
        vo.addList(feedbackIPage);
        vo.ok();
        log.info("user feedback list end");
        return vo;
    }
}
